import React,{ useState,useMemo} from 'react';

function Example8(){
    const[yifei,setYifei]=useState('亦菲来了')
    const[nini,setNini]=useState('倪妮来了')
    return(
        <>
            <button onClick={()=>{setYifei(new Date().getTime())}}>亦菲</button>
            <button onClick={()=>{setNini(new Date().getTime()+'倪妮过来了')}}>倪妮</button>
            <ChildCompent name={yifei}>{nini}</ChildCompent>
        </>
    )
}

function ChildCompent({name,children}){
    function changeYifei(){
        console.log('亦菲过来了')
        return name+'亦菲过来了'
    }
    const newYifei=useMemo(()=>changeYifei(name),[name]);
    return(
        <>
            <div>{newYifei}</div>
            <div>{children}</div>
        </>
    )
}
export default Example8